package controller

import (
	"gin_reptile/pkg/db"
	"github.com/gin-gonic/gin"
	"net/http"
)

func GetData(c *gin.Context) {
	type DbVo struct {
		Name      string `json:"name"`
		Buy       string `json:"buy"`
		Sell      string `json:"sell"`
		CreatedAt string `json:"created_at"`
	}
	var dbList []DbVo
	orm, err := db.GetDBInstance()
	if err != nil {
		panic("连接数据库异常")
	}
	if err = orm.Model("fx_reptile_money").Order("created_at desc").Limit(7).
		Scan(&dbList); err != nil {
		panic("数据查询异常")
	}
	c.JSONP(http.StatusOK, gin.H{
		"meta": gin.H{
			"code": 200,
			"msg":  "",
		},
		"data": dbList,
	})
}
